// pages/jilu/show/show.js

Page({

    /**
     * 页面的初始数据
     */
    data: {
        cla_l: 'select',
        cla_r: '',
        ur: {},

        uis: [],

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

        var that = this
        that.setData({

            ur: JSON.parse(options.ur),
            uis: JSON.parse(options.uis),
        })

        app.log('==>>ur:')
        app.log(that.data.ur)

        that.action_data()

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    toExplain: function (e) {
        var that = this
        let index = e.currentTarget.dataset['index'];
        app.log(index)

        wx.navigateTo({
            url: '/pages/jilu/explain/explain?ui=' + JSON.stringify(that.data.uis[index])
        })
    },
    action_data() {
        app.log('==>>action_data')
        var that = this
        for (let i in that.data.ur) {
            let name = i.replace("result", "").toUpperCase()
            for (let j in that.data.uis) {
                if (name == that.data.uis[j].nameEng) {
                    for (let k = 0; k < that.data.uis[j].labelArray.length; k++) {
                        if ((that.data.ur[i].indexOf("(") > -1 && that.data.ur[i].indexOf(that.data.uis[j].labelArray[k]) > -1)
                            || that.data.ur[i] == that.data.uis[j].limitArray[k]) {
                            that.data.uis[j].nameValue = that.data.ur[i]
                            that.data.uis[j].pointIndex = k
                            that.data.uis[j].state = that.data.uis[j].resultArray[k]
                            break
                        }

                    }

                }
            }
        }

        app.log('==>>結果：')
        app.log(that.data.uis)
        that.setData({
            uis: that.data.uis
        })
    },
    sel: function (e) {

        var that = this
        let value = e.currentTarget.dataset['v']

        if (value == 'l') {
            that.setData({
                cla_l: 'select',
                cla_r: '',
            })
        } else if (value == 'r') {

            that.setData({
                cla_l: '',
                cla_r: 'select',
            })
        }
    }
})